﻿// CPropertyEditor.cpp: 实现文件
//

#include "pch.h"
#include "CPropertyEditor.h"
#include "afxdialogex.h"
#include"Spectrum.h"
#include"resource.h"



// CPropertyEditor 对话框

IMPLEMENT_DYNAMIC(CPropertyEditor, CDialogEx)

CPropertyEditor::CPropertyEditor(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_DIALOG1, pParent)
{

}

CPropertyEditor::~CPropertyEditor()
{
}

void CPropertyEditor::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_TREE1, m_Tree);
	DDX_Control(pDX, IDC_BUTTON1, m_ButtonColor);
}


BEGIN_MESSAGE_MAP(CPropertyEditor, CDialogEx)
	ON_BN_CLICKED(IDC_BUTTON1, &CPropertyEditor::OnBnClickedButton1)
	ON_WM_PAINT()
END_MESSAGE_MAP()


// CPropertyEditor 消息处理程序


BOOL CPropertyEditor::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	// TODO:  在此添加额外的初始化


	HTREEITEM hRoot;  //书的跟节点的句柄
	HTREEITEM hCataIteam;  //可表示任一文章的句柄
	HTREEITEM hArtItem;  //可表示任一文章的句柄

	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	HICON icon[5];
	icon[0]= AfxGetApp()->LoadIconW(IDI_ICON1);
	icon[1]= AfxGetApp()->LoadIconW(IDI_ICON2);
	icon[2]= AfxGetApp()->LoadIconW(IDI_ICON3);
	icon[3] = AfxGetApp()->LoadIconW(IDI_ICON4);
	icon[4] = AfxGetApp()->LoadIconW(IDI_ICON5);
	m_imagelist.Create(23, 23, ILC_COLOR32, 3, 3);
	for (int  i = 0; i < 5; i++)
	{
		m_imagelist.Add(icon[i]);
	}
	
	m_Tree.SetImageList(&m_imagelist, TVSIL_NORMAL);
	
	hRoot = m_Tree.InsertItem(_T("成功导入的数据："), 0, 0, TVI_ROOT);  //跟结点
	hCataIteam = m_Tree.InsertItem(_T("假装是个数据"), 1, 1, hRoot, TVI_LAST); // 子结点
	hArtItem = m_Tree.InsertItem(_T("假装是个数据"), 2, 2, hRoot, TVI_LAST); // 子结点,注意数字
	hArtItem = m_Tree.InsertItem(_T("假装是个数据"), 3, 3, hRoot, TVI_LAST); // 子结点,注意数字
	hArtItem = m_Tree.InsertItem(_T("假装是个数据"), 4, 4, hRoot, TVI_LAST); // 子结点,注意数字
	m_Tree.Expand(hRoot, TVE_EXPAND);  // 展开结点


	/////////////////////////////////////////////////////////////////////////////////////////////////////

	

	
	








	return TRUE;  // return TRUE unless you set the focus to a control
				  // 异常: OCX 属性页应返回 FALSE




}


void CPropertyEditor::OnBnClickedButton1()//弹出颜色对话框
{
	// TODO: 在此添加控件通知处理程序代码
	CColorDialog cd;
	if (cd.DoModal()==IDOK)
	{
		m_Color = cd.GetColor();
		

	}
	int r = BYTE(m_Color);
	int b = BYTE(m_Color >> 8);
	int g = BYTE(m_Color >> 16);
	//int a = BYTE(m_Color >> 24);
	CString rs,gs,bs,kz,ky,md;
	rs.Format(_T("%d"), r);
	gs.Format(_T("%d"), g);
	bs.Format(_T("%d"), b);
	kz = "(";
	ky = ")";
	md = ",";

	CString RGB;
	RGB = kz + rs + md + gs + md + bs + ky;

	m_ButtonColor.SetWindowTextW(RGB);

	
	



}


void CPropertyEditor::OnPaint()
{
	CPaintDC dc(this); // device context for painting
					   // TODO: 在此处添加消息处理程序代码
					   // 不为绘图消息调用 CDialogEx::OnPaint()


	

}
